package org.td.engine.combat;

import org.td.engine.entity.tower.Turret;

public abstract class AbstractWeapon implements Weapon {
    
    protected Turret owner;
    protected WeaponClass weaponClass;
    protected float cooldown;
    
    public AbstractWeapon(WeaponClass weaponClass, Turret owner) {
        this.weaponClass = weaponClass;
        this.owner = owner;
        
    }
    
    @Override
    public boolean isCharged() {
        return cooldown <= 0;
    }
    
    @Override
    public void update(float time) {
        if (cooldown > 0) {
            cooldown -= time;
            if (cooldown < 0) {
                cooldown = 0;
            }
        }
    }
    
    @Override
    public WeaponClass getWeaponClass() {
        return weaponClass;
    }
}
